<?php
header('Content-Type: text/html; Charset=UTF-8');
$rows = array();

$id = isset($_GET['id'])?$_GET['id']:0;
try {
	$pdo = new PDO('mysql:dbname=study01;host=localhost','root','0000');
	$pdo->query("SET NAMES UTF-8");
	//$id = 2;
  $sql = 'select * from t_student where id='.$id;
	$stmt = $pdo->prepare($sql);
	$flag = $stmt->execute();

	$row = $stmt->fetchAll();

	//var_dump($row);
	if(!$flag){
		echo "error....";
	  }
   }catch (PDOException $e){
	 echo 'Connection failed: ' . $e->getMessage();
   }
?>

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>课堂练习</title>
</head>

<body>
	<div>显示所有学生</div>
	<table border="1" style="width:100%">
	<tr>
		<td>ID</td>		<td>姓名</td>		<td>年龄</td>		<td>性别</td>
	</tr>
    </table>
	<tr>
		<td><?php echo $item['id'] ?></td>
        <td><?php echo $item['name'] ?></td>
		<td><?php echo $item['age'] ?></td>
		<td><?php echo $item['gender']==1 ?'男':'女' ?></td>
  </tr>
<?php endforeach ?>

<div>显示所有课程</div>
	<table border="1" style="width:100%">
	<tr>
		<td>ID</td>		<td>课程</td>
	</tr>
    </table>
	<tr>
		<td><?php echo $item['id'] ?></td>
        <td><?php echo $item['name'] ?></td>
  </tr>
<?php endforeach ?>

<div>显示所有班级</div>
	<table border="1" style="width:100%">
	<tr>
		<td>ID</td>		<td>班级</td>
	</tr>
    </table>
	<tr>
		<td><?php echo $item['id'] ?></td>
        <td><?php echo $item['name'] ?></td>
  </tr>
<?php endforeach ?>

<div>显示所有老师</div>
	<table border="1" style="width:100%">
	<tr>
		<td>ID</td>		<td>老师</td>
	</tr>
    </table>
	<tr>
		<td><?php echo $item['id'] ?></td>
        <td><?php echo $item['name'] ?></td>
  </tr>
<?php endforeach ?>
</body>
</html>
